import React, { Component } from 'react';
import PropTypes from 'prop-types';

import "./commentItem.css"

class CommentItem extends Component {

	handleDel = () => {
		const { comment, delComment, index } = this.props
		if (window.confirm(`确认删除${comment.username}的评论?`)) {
			delComment(index)
		}
	}
	render() {
		const { comment } = this.props
		return (

			<li className="list-group-item">
				<div className="handle">
					<a href="javascript:;" onClick={this.handleDel}>删除</a>
				</div>
				<p className="user"><span>{comment.username}</span><span>说:</span></p>
				<p className="centence">{comment.content}</p>
			</li>

		)
	}
}

CommentItem.propTypes = {
	comment: PropTypes.object.isRequired,
	delComment: PropTypes.func.isRequired,
	index: PropTypes.number.isRequired,
}
export default CommentItem